package vno.sci.window
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import org.aswing.AsWingConstants;
	import org.aswing.AsWingManager;
	import org.aswing.AssetBackground;
	import org.aswing.BoxLayout;
	import org.aswing.JButton;
	import org.aswing.JWindow;
	import org.aswing.SoftBoxLayout;
	
	import vno.sci.event.ToolbarEvent;

	public final class Toolbar extends JWindow
	{
		private var buttons:Array = new Array();
		// Layout may be changed later.
		private var buttonLayout:BoxLayout= new BoxLayout(BoxLayout.X_AXIS,10);
				
		public function Toolbar(owner:* = null, model:Boolean = false)
		{
			super(owner, model);
			setBackgroundDecorator(new AssetBackground(new Bitmap (new BitmapData(200,20,false,0x123456))));
			super.getContentPane().setLayout(new SoftBoxLayout(SoftBoxLayout.X_AXIS,20,AsWingConstants.RIGHT));
		}
		public function pushButton(btn:MyButton):void
		{
			buttons.push(btn);
			super.getContentPane().append(btn);
			btn.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		protected function onClick(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			event.stopImmediatePropagation();
			dispatchEvent(new ToolbarEvent(event.target.id));
		}
	}
}